First dealing with data

# install.packages("readxl")
readxl::read_excel("data_dec/water_stress.xlsx")
## # A tibble: 1,260 × 23
##    Group Week  Date                Species PlantId Use   Treat…¹ Soil_…² Elect…³
##    <chr> <chr> <dttm>              <chr>   <chr>   <chr> <chr>     <dbl>   <dbl>
##  1 G1    W1    2022-10-05 00:00:00 Solanu… Slc1    cult… c          55.6    1.31
##  2 G1    W1    2022-10-05 00:00:00 Solanu… Slc2    cult… c          52.7    1.28
##  3 G1    W1    2022-10-05 00:00:00 Solanu… Slc3    cult… c          61.3    1.24
##  4 G1    W1    2022-10-05 00:00:00 Solanu… Slc4    cult… c          51      1.36
##  5 G1    W1    2022-10-05 00:00:00 Solanu… Slc5    cult… c          52.1    1.39
##  6 G1    W1    2022-10-05 00:00:00 Solanu… Slc6    cult… c          54.4    1.24
##  7 G1    W1    2022-10-05 00:00:00 Solanu… Slc7    cult… c          51.6    1.51
##  8 G1    W1    2022-10-05 00:00:00 Amaran… Arc1    wild  c          54.6    1.68
##  9 G1    W1    2022-10-05 00:00:00 Amaran… Arc2    wild  c          50.9    1.93
## 10 G1    W1    2022-10-05 00:00:00 Amaran… Arc3    wild  c          67.2    1.89
## # … with 1,250 more rows, 14 more variables: Too_dry <chr>, Plant_height <dbl>,
## #   Leaf_number <dbl>, Leaf_length <dbl>, Leaf_width <dbl>, Leaf_area <dbl>,
## #   Chlorophyll_content <dbl>, Aerial_fresh_weight <dbl>,
## #   Aerial_dry_weight <dbl>, Root_length <dbl>, Roots_fresh_weight <dbl>,
## #   Roots_dry_weight <dbl>, Mortality <chr>, Comments <lgl>, and abbreviated
## #   variable names ¹​Treatment, ²​Soil_humidity, ³​Electrical_conductivity
d0 <- readxl::read_excel("data_dec/water_stress.xlsx", sheet = "Data")

Visualization of data with plots. Create many plots.

One plot for each species with variables and treatments (control, intermediate, waterstress)

X= Date Y= Variable Y1= Plant height Y2= Leaf number Y3= Leaf lenght Y4= Leaf width Y5= Leaf area Y7= Chlorophyll

S1 : Solanum lycopersicum

#install.packages("ggplot2", dependencies = TRUE)
library(ggplot2)

# All species
ggplot(d0, aes(x= Date, y= Plant_height, group= PlantId, color= Treatment)) + 
  geom_line()+
  facet_grid( Species ~. )
## Warning: Removed 3 rows containing missing values (`geom_line()`).

# For Solanum lycopersicum
s1 <- d0[d0$Species=="Solanum lycopersicum",]
ggplot(s1, aes(x= Date, y= Plant_height, group= PlantId, color= Treatment)) + 
  geom_line()

#For loop = for all the species

#essai1
v1 <- c("Plant_height", "Chlorophyll_content" ,"Roots_dry_weight")

for(i in levels(as.factor(d0$Species))) {
  for(variable in v1) {
    s1 <- d0[d0$Species==i,]
    ggplot(s1, aes(x= Week, y= s1[ ,v1], group= PlantId, color= Treatment)) + 
      geom_line()
  }
}

#essai2
for(i in levels(d0$Species)) {
  for(variable in 1:10) {
    s2 <- d0[d0$Species,]
    ggplot(s2, aes(x= Date, y= Plant_height, group= PlantId, color= Treatment)) + 
      geom_line()
  }
}

#essai3
for(i in levels(d0$Species)){
  tf <- d0$Species=="Solanum lycopersicum"
  ggplot(tf, aes(x = Date, y= Plant_height, group= PlantId, color= Treatment)) + 
      geom_line()
}

#essai4
for(i in 2:ncol(d0)) {                      
  print(ggplot(d0, aes(x= Date, y= Plant_height, group= PlantId, color= Treatment, data[ , i])) +
          geom_line())
  Sys.sleep(2)
}
## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

## Warning: Removed 3 rows containing missing values (`geom_line()`).

S2 : Amaranthus retroflexus

S3 : Spinacia oleracea

S4 : Amaranthus retroflexus

S5 : Hordeum vulgare

S6 : Lolium perenne

S7 : Beta vulgaris

S8 : Sonchus oleraceus

S9 : Portulacea oleracea

S10 : Raphanus sativus

Plot for